﻿using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Linq;
using System.Web;

namespace Propro.Models
{
    public class ProWebContext : DbContext
    {
        public ProWebContext()
            : base("DefaultConnection")
        {

        }

        public DbSet<UserProfile> Users { get; set; }
        public DbSet<Project> Projects { get; set; }
        public DbSet<Log> Logs { get; set; }
        public DbSet<Downloads> Downloads { get; set; }
        public DbSet<Updates> Updates { get; set; }

        protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
            modelBuilder.Entity<Project>().
                HasMany(c => c.Members).
                WithMany(p => p.Projects).
                Map(
                m =>
                {
                    m.MapLeftKey("ProjectId");
                    m.MapRightKey("UserId");
                    m.ToTable("ProjectUserProfiles");
                });
            base.OnModelCreating(modelBuilder);
        }

    }

}